<!DOCTYPE html>
<html>
<head>
    <title>搜索内容</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/userTravels.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>
    <script>
        $(function () {


            $('.strategy').click(function () {//点击a标签
                if ($('.strategy').is(':hidden')) {//如果当前隐藏
                    $('.strategy').show();//那么就显示div
                    $(this).addClass("nav-item")
                } else {//否则
                    $('.strategy').remove();//就隐藏div
                    $(this).removeClass("nav-item")
                }
            })


            $('.newsPage').click(function () {//点击a标签
                if ($('.newsPage').is(':hidden')) {//如果当前隐藏
                    $('.newsPage').show();//那么就显示div
                    $(this).addClass("nav-item")
                } else {//否则
                    $('.newsPage').remove();//就隐藏div
                    $(this).removeClass("nav-item")
                }
            })

            $('.travel').click(function () {//点击a标签
                if ($('.travel').is(':hidden')) {//如果当前隐藏
                    $('.travel').show();//那么就显示div
                    $(this).addClass("nav-item")
                } else {//否则
                    $('.travel').remove();//就隐藏div
                    $(this).removeClass("nav-item")
                }
            })
            var params = getParams();
            var keyword = decodeURIComponent(params.keyword);

            $(".search p").html("您搜索的内容是:" + keyword);

      //      $(".search p").html("老大你随便看看 ~ 3~ ");



            //当前页
            var currentPage = 1;
            //总页数
            var pages;
            //存储游记的数组
            var travelArr = [];

            function query() {

                //获取我的

                $.get(baseUrl + '/Search/queryStrategy' + '?keyword=' + params.keyword, {currentPage: currentPage}, function (data) {


                    //把第二个数组合并第一个数组中
                    console.log(data);
                    $.merge(travelArr, data.list);
                    var json = {
                        list: travelArr
                    };
                    //渲染数据
                    $(".strategy").renderValues(json, {
                        getHref: getHref

                    });
                    //    console.log(json);

                    //获取总页数
                    pages = data.pages;


                })


                $.get(baseUrl + '/Search/queryTravel' + '?keyword=' + params.keyword, {currentPage: currentPage}, function (data) {
                    //把第二个数组合并第一个数组中
                    console.log(data);
                    $.merge(travelArr, data.list);
                    var json = {
                        list: travelArr
                    };
                    //渲染数据
                    $(".travel").renderValues(json, {
                        getHref: getHref

                    });
                    console.log(json);

                    //获取总页数
                    pages = data.pages;
                })


                currentPage = currentPage + 1;
            }

            //默认查询第一页
            query();

            //给window绑定滚动事件
            $(window).scroll(function () {
                if ($(window).height() + $(document).scrollTop() + 50 >= $(document).height()) {
                    //如果是小于总页数就发送请求
                    if (currentPage <= pages) {
                        query();
                    } else {
                        $(document).dialog({
                            type: 'notice',
                            content: '<span class="info-text">亲,已经到底了!</span>',
                            autoClose: 2500
                        });
                    }
                }
            });
        });
    </script>
</head>


<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col-2">
            <a href="javascript:history.go(-1);">
                <span><i class="fa fa-chevron-left fa-2x"></i></span>
            </a>
        </div>
        <div class="col-8">
            <div class="input-group-sm search">
                <p style="color: white; font-size: 20px"></p>
            </div>
        </div>
    </div>
</div>

<ul class="nav nav-pills nav-justified border border-left-0 border-top-0 border-right-0" id="pills-tab" role="tablist">

    <li class="nav-item" style="width: 33%">
        <a role="button" id="strategy" class="nav-link clickTab active show" data-type="1" data-toggle="pill"
           href="#pills-strategy">
            <span class="strategy">攻略(再点一次接去掉)</span>
        </a>

    </li>

</ul>
<ul class="nav nav-pills nav-justified border border-left-0 border-top-0 border-right-0" id="pills-tab2" role="tablist">
    <li class="nav-item" style="width: 33%">
        <a role="button" id="newsPage" class="nav-link clickTab" data-type="3" data-toggle="pill"
           href="#pills-newsPage" type="hidden">
            <span class="newsPage"></span>
        </a>
    </li>
</ul>
<ul class="nav nav-pills nav-justified border border-left-0 border-top-0 border-right-0" id="pills-tab3" role="tablist">
    <li class="nav-item" style="width: 33%">
        <a role="button" id="travel" class="nav-link clickTab" data-type="2" data-toggle="pill" href="#pills-travel">
            <span class="travel">游记(再点一次接去掉)</span>
        </a>
    </li>


</ul>


<div class="tab-content travels" id="pills-tabContent">
    <div class="tab-pane fade active show">

        <div class="container strategy">
            <div render-loop="list">
                <a data-url="strategyDetails.html?id=" render-fun="getHref" render-key="list.strategyDetail.id">
                    <p render-html="list.strategyDetail.title">标题:</p>
                    <img render-src="list.strategyDetail.coverUrl" width="100%">
                </a>
            </div>
        </div>
        <hr>

    </div>


    <div class="tab-content travels" id="Content">
        <div class="tab-pane fade" id="pills-travel">

            <div class="container travel">
                <div render-loop="list">
                    <a data-url="travelContent.html?id=" render-fun="getHref" render-key="list.travel.id">
                        <p render-html="list.travel.title">标题:</p>
                        <img render-src="list.travel.coverUrl" width="100%">
                    </a>
                </div>
            </div>
            <hr>
        </div>
        <!--<div render-loop="list">
            <div class="container commend">
                <a data-href="travelContent.html?id=" render-fun="getHref" render-key="list.id">
                    <p render-html="list.title"></p>
                    <img render-src="list.coverUrl">
                </a>
            </div>
            <hr>
        </div>-->
    </div>
    <div class="tab-pane fade" id="pills-newsPage">
        <!--<div render-loop="list">
            <div class="container commend">
                <a data-href="newsContent.html?id=" render-fun="getHref" render-key="list.id">
                    <p render-html="list.title"></p>
                    <img render-src="list.coverUrl">
                </a>
            </div>
            <hr>
        </div>-->
    </div>
</div>
</body>

</html>
